#ifndef _SYSTEM_UART_H
#define _SYSTEM_UART_H

#include <stdio.h>
#include <string.h>
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"

#define SYSTEM_UART_TX_CLOCK    RCC_AHB1Periph_GPIOD
#define SYSTEM_UART_RX_CLOCK    RCC_AHB1Periph_GPIOD
#define SYSTEM_UART_CLOCK       RCC_APB1Periph_USART2
#define SYSTEM_UART_EXTI_CLOCK  RCC_APB2Periph_SYSCFG

#define SYSTEM_UART_TX_PORT     GPIOD
#define SYSTEM_UART_RX_PORT     GPIOD
#define SYSTEM_UART_TX_PIN      GPIO_Pin_5
#define SYSTEM_UART_RX_PIN      GPIO_Pin_6

#define SYSTEM_UART_TX_SOURCE   GPIO_PinSource5
#define SYSTEM_UART_RX_SOURCE   GPIO_PinSource6

#define SYSTEM_UART         	USART2
#define SYSTEM_UART_BAUD    	115200

#define PAK_HEAD            	0XAB

typedef enum
{
    HEAD,
    LENGTHH,
    LENGTHL,
    COMMAND,
    RECERROR,
    RECSUCCESS
}PACKAGE;

void system_uart_init(void);
void send_char(USART_TypeDef * pUSARTx,uint8_t ch);
void system_putc(uint8_t ch);
void system_puts(char* str);
void receive_data(USART_TypeDef * pUSARTx);
void memory_reset(uint8_t* mem, uint16_t bindex, uint16_t eindex, uint8_t vlaue);

#endif //_SYSTEM_UART_H